package com.xjtu.service;

import com.xjtu.model.Chat;
import com.xjtu.repository.ChatRepository;
import com.xjtu.view.EventVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;


@Slf4j
@Service
public class DemoService {

    @Resource
    private ChatRepository chatRepository;


    public void saveChat(Chat chat) {
        chatRepository.save(chat);
    }


    public List<Chat> find(String from, String to) {
        Query query = new Query(Criteria.where("read").is(false));
        List<Chat> chats = chatRepository.find(query);
        return chats;
    }


    public List<Chat> findAll() {
        return chatRepository.findAll();
    }


    // @RabbitListener(queues = "bed-1")
    // public void bed1(byte[] message) {
    //     log.info("1号床收到：" + new String(message));
    // }
    //
    // @RabbitListener(queues = "bed-2")
    // public void bed2(byte[] message) {
    //     log.info("2号床收到：" + new String(message));
    // }
    //
    // @RabbitListener(queues = "bed-3")
    // public void bed3(byte[] message) {
    //     log.info("3号床收到：" + new String(message));
    // }
    //
}
